#include <opencv2/opencv.hpp>
#include <iostream>
#include <filesystem>

int main() {
    // 判断文件是否存在
     if (std::filesystem::exists("../LingXiao.png")) {
        std::cout << "File exists!" << std::endl;
    } else {
        std::cout << "File does not exist!" << std::endl;
        return 0;
    }
    // 以彩色方式读取图像
    cv::Mat image = cv::imread("../LingXiao.png", 1);
    // 检查图像是否成功读取
    if (image.empty()) {
        std::cerr << "Could not open or find the image!" << std::endl;
        return -1;
    }
    // 以LingXiao为标题显示图像
    cv::imshow("LingXiao", image);
    
    // 等待ESC按键并关闭窗口
    int key = 0;
    while(key != 27)
    {
        key = cv::waitKey();
        std::cout << "key:" << key <<std::endl;
    }
    cv::destroyAllWindows();
    return 0;
}
